CXX = g++  
CXXFLAGS = -std=c++11 -Wall  
LATEX := xelatex  

# 源文件  
SOURCES = ProblemA.cpp ProblemC+D.cpp ProblemE.cpp \
		testCircle.cpp ppSpline.cpp polynomial.cpp \
		dividedDiff.cpp linearEqnSolver.cpp Function.cpp  
  
# 目标文件  
OBJECTS = $(SOURCES:.cpp=.o)  

# 简并
FILEO = polynomial.o dividedDiff.o \
		linearEqnSolver.o Function.o
  
# 可执行文件  
EXECUTABLE = AnswerA AnswerC+D AnswerE testCircle
  
.PHONY: all clean  
  
all: $(EXECUTABLE) 
  
AnswerA: ProblemA.o ppSpline.o $(FILEO) 
	$(CXX) $(CXXFLAGS) $^ -o $@

AnswerC+D: ProblemC+D.o $(FILEO) 
	$(CXX) $(CXXFLAGS) $^ -o $@

AnswerE: ProblemE.o ppSpline.o $(FILEO) 
	$(CXX) $(CXXFLAGS) $^ -o $@

testCircle: testCircle.o ppSpline.o $(FILEO)
	$(CXX) $(CXXFLAGS) $^ -o $@

%.o: %.cpp  
	$(CXX) $(CXXFLAGS) -c $< -o $@  
  
run:
	./AnswerA
	./AnswerC+D
	./AnswerE
	./testCircle

clean:  
	rm -f $(OBJECTS) $(EXECUTABLE) \
	*.aux *.log *.out *.bbl *.pdf \
	*.blg *.bcf *.xml *.gz \
	output/ProblemA_data/*.aux* output/ProblemA_data/*.log \
	output/ProblemA_data/*.pdf output/ProblemA_data/*.dep \
	output/ProblemA_data/*.dpth output/ProblemA_data/*.md5

report: report.pdf  

report.pdf: complete.pdf second.pdf natural.pdf  
	$(LATEX) report.tex  
	$(LATEX) report.tex  

complete.pdf:  
	cd output/ProblemA_data && xelatex -shell-escape complete.tex  

second.pdf:  
	cd output/ProblemA_data && xelatex -shell-escape second.tex  

natural.pdf:  
	cd output/ProblemA_data && xelatex -shell-escape natural.tex  